package com.jokerku.lottery.infrastructure.common;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: guzq
 * @CreateTime: 2022/08/31 10:46
 * @Description: 事件类型枚举
 * @Version: 1.0
 */
public enum EventTypeEnum {

    TEXT("text"),
    EVENT("event"),
    ;


    private String desc;

    EventTypeEnum(String desc) {
        this.desc = desc;
    }

    private static final Map<String, EventTypeEnum> ENUM_MAP;

    static {
        ENUM_MAP = new ConcurrentHashMap<>();
        ENUM_MAP.put(TEXT.desc, TEXT);
        ENUM_MAP.put(EVENT.desc, EVENT);
    }

    public static EventTypeEnum getByStr(String str) {
        Assert.isTrue(StringUtils.isNotBlank(str), "EventTypeEnum cannot be null");

        return ENUM_MAP.get(str);
    }
}
